package com.framework.service.core.controller;

import com.framework.common.Enums.FrameworkErrorCodeEnum;
import com.framework.common.controller.BaseController;
import com.framework.common.domain.R;
import com.framework.service.core.service.ICityService;
import com.framework.core.api.request.CityQueryReq;
import com.framework.core.api.response.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zhoubb
 * @version V1.0
 * @Date 2020/4/14 0:18
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/api")
@Api(value = "openApi", description = "免授权服务接口")
public class ApiController extends BaseController {

    @Autowired
    private ICityService cityService;



    @ApiOperation(value = "带条件查询城市列表", httpMethod = "GET")
    @RequestMapping(value = "/citylist",method = RequestMethod.GET)
    @ResponseBody
    public R listCityByCondition(CityQueryReq cityQueryReq) {
        List<CityQueryRes> cityQueryResList = cityService.listCityByCondition(cityQueryReq);
        if(cityQueryResList != null) {
            return R.okData(cityQueryResList);
        }
        return R.error(FrameworkErrorCodeEnum.SYSTEM_ERR);
    }

    @ApiOperation(value = "查询所有城市列表", httpMethod = "GET")
    @RequestMapping(value = "/citylistAll",method = RequestMethod.GET)
    @ResponseBody
    public R listCityAll() {
        List<CityDataRes> cityDataResList = cityService.listCityAll();
        if(cityDataResList != null) {
            return R.okData(cityDataResList);
        }
        return R.error(FrameworkErrorCodeEnum.SYSTEM_ERR);
    }

}
